package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.AccountApply;
import com.briup.jz.bean.AccountSystem;
import com.briup.jz.bean.extend.AccountApplyExtend;
import com.briup.jz.service.IAccountApplyService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@Validated
@RequestMapping("/AccountApply")
@Api(description = "账户变动申请表（提现）")
public class AccountApplyController {

	
	@Autowired
	private IAccountApplyService IAS;
    @GetMapping("/findAll")
	@ApiOperation("查询所有信息")
	public List<AccountApply> findAll(){
		return IAS.findAll();	
	}
    

    @GetMapping("/CheckNoPass")
    @ApiOperation(value="审核不通过")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query",dataType="long",required = true),
        @ApiImplicitParam(name="reason",value = "原因",paramType = "query",required = true)
})
    public Message changeStatuestoNocheckPass(long id,String reason) {
    	IAS.changeStatus(id,"不通过",reason);
		return MessageUtil.success("更改成功！");
    }
    
    @GetMapping("/CheckPass")
    @ApiOperation(value="审核通过")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query",dataType="long",required = true),
        @ApiImplicitParam(name="reason",value = "原因",paramType = "query",required = true)
})
    public Message changeStatuestoCheckPass(long id,String reason) {
    	IAS.changeStatus(id,"通过",reason);
		return MessageUtil.success("更改成功！");
    }
    
    @ApiOperation(value = "撤销账户变动信息")
    @GetMapping("/deleteById")
    @ApiImplicitParams({
    @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
    })
    public Message deleteById(@NotNull Long id){
    	IAS.deleteById(id);
        return MessageUtil.success("撤销成功！");
    }

    @ApiOperation(value = "提交账户变动申请信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "主键",paramType = "form",required = true),
            @ApiImplicitParam(name="money",value = "资金",paramType = "form"),
            @ApiImplicitParam(name="applyType",value = "申请类型（充值OR提现）",paramType = "form"),
            @ApiImplicitParam(name="applyTime",value = "申请时间",paramType = "form"),
            @ApiImplicitParam(name="status",value = " 状态",paramType = "form"),
            @ApiImplicitParam(name="userId",value = "userid",paramType = "form"),
            @ApiImplicitParam(name="reason",value = "原因",paramType = "form")
    })
    @PostMapping("/saveOrUpdate")
    public Message saveOrUpdate(AccountApply AA){
    	IAS.saveOrUpdate(AA);
        return MessageUtil.success("更新成功");
    }
    @ApiOperation("分页查询")
    @GetMapping("/pageQuery")
    public Message pageQuery(int page, int pageSize, String status,String type,Long beginTime,Long endTime,Long user_id) {
    	List<AccountApplyExtend> lists=IAS.pageQuery(page, pageSize, status, type, beginTime, endTime,user_id);
		return MessageUtil.success(lists);
    }
}
